﻿@model CanDichVU.ViewModels.AdminBrowseImageViewModel
 
@{
    Layout = null;
}
 
<!DOCTYPE html>
 
<html>
<head>
    @*<link href="@Url.Content("~/Content/themes/caffeinated/style.css")" type="text/css" rel="stylesheet">*@
    <title>BrowseImage</title>
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-ui-1.8.24.js")"></script>
    <script src="/Scripts/jquery-explr-1.4.js"></script>
    <link href="/Content/jquery-explr-1.4.min.css" rel="stylesheet" />
    <link href="/Scripts/jquery-loadmask/jquery.loadmask.css" rel="stylesheet" />
    <script src="/Scripts/jquery-loadmask/jquery.loadmask.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#load_tree_images').explr({ startCollapsed: false });
            //$("a.path_images").click(function () {
            //    window.opener.CKEDITOR.tools.callFunction($("#CKEditorFuncNum").val(), $(this).attr("data-images-path"));
            //});

            $("#load_tree_images a").click(function () {
                makeloading();
                var psths = $(this).attr("data-path");
                $.get("/Upload/BrowseFindImageOnPath?Paths=" + psths, function (data) {
                    $(".images_info").html(data);
                    $("#images_info").unmask();
                });
            });

        });

        function makeloading() {
            $("#images_info").mask("Dữ liệu đang xử lý...");
        }

        function getpathandfind(p) {
            var funcNum = getUrlParam('CKEditorFuncNum');
            //var paths = $(this).attr("data-images-path");
            window.opener.CKEDITOR.tools.callFunction(funcNum, p);
            this.close();
        }

        function getUrlParam(paramName) {
            var reParam = new RegExp('(?:[\?&]|&)' + paramName + '=([^&]+)', 'i');
            var match = window.location.search.match(reParam);

            return (match && match.length > 1) ? match[1] : null;
        }

    </script>

    <style type="text/css">
        .left_page
        {
            width:300px;
            float:left;
            height:500px;
            overflow:hidden;
            border-right:1px solid #ccc;
        }

        #load_tree_images
        {
            width:300px;
            overflow:hidden;
        }

        .images_info
        {
            float:left;
        }

    </style>

</head>
<body>
    <div>
        @Html.HiddenFor(model => model.CKEditorFuncNum)
        <div class="left_page">
                <ul id="load_tree_images">
                    <li>
                        <a href="javascript:void(0)" data-path="">Thực mục upload</a>
                        @Html.Action("ListFolderTreeView", "Upload", new { forder = "/Content/uploads/" })
                    </li>
            </ul>

        </div>
        <div class="images_info" id="images_info">
            @if (Model.ListForder != null)
            {
                foreach (var vPath in Model.ListForder)
                    {
                        <div style="float: left; width: 100px; display: block; padding: 10px;">
                            <div>
                                @*<div>
                                    <a class="path_images" href="javascript: return false;">@vPath.name</a>
                                </div>*@
                                <div style="display: inline;">
                                    <a class="path_images" onclick="return getpathandfind('@vPath.Path');" data-images-path="@vPath.Path" href="javascript:void(0)">
                                        <img style="width:100px; padding: 10px;" src="@vPath.Path"/>
                                    </a>
                                </div>
                            </div>
                 
                        </div>
                    }
            }
        </div>
        
    </div>
</body>
</html>